package com.cc.utils.poi.dao.template;

import com.cc.utils.poi.dao.excellbasic.ExcellSheetBasic;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;

/**
 * @User c.c
 * @Since 2022/12/16
 * @Time 13:45
 * @Description
 */

public abstract class GlobalTemplate<T> implements ExcellTemplate<T> {
  @Override
  public ExcellSheetBasic<T> initSheet(String tableName) {
    ExcellSheetBasic<T> workbook = ExcellSheetBasic.getInstance(tableName);
    return workbook;
  }

  /**
   * 只设置了基础样式
   *
   * @param cellStyle 基础style
   * @return HSSFCellStyle
   * @author C.c
   * @since 2022-12-16 14:10
   **/
  @Override
  public HSSFCellStyle setStyly(HSSFCellStyle cellStyle) {
    cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 居中
    return cellStyle;
  }

  /**
   * 设置字体基础样式
   *
   * @param font 字体
   * @return HSSFFont
   * @author C.c
   * @since 2022-12-21 09:43
   **/
  @Override
  public HSSFFont setfront(HSSFFont font) {
    font.setFontHeightInPoints((short) 14); //字体大小
    font.setFontName("宋体"); //什么字体
    return font;
  }

}
